<% table_id = "table_#{table.id}" -%>
<table	class="blue box table"
				cellspacing="0"
				id="<%= h(table_id) %>"
				summary="<%= h(table.summary) %>"
				style="left:<%= table.x %>px; top:<%= table.y %>px; ">
	<colgroup>
		<col id='name' />
		<col id='delete' />
		<col id='changeBtn' />
		<col id='deleteBtn' />
	</colgroup>
	<caption><span style="display: none;"><%= h(table.summary) %></span></caption>
	<thead class="line">
			<tr class="deepBlue">
			<% if (session[:user_id] == @people.id) %>
				<th><%= link_to table.tableName, {:controller => :user_admin, :action => 'edit_table', :id => table}, 
																	:class => "plus bold", :title => "edit" 	%></th>
				<th></th>
				<th><%= link_to '×', {:controller => :user_admin, :action => :delete_table, :id => table}, 
											:class => "x", :title => "delete" %></th>				
			<% else %>
				<th class="bold"> <%= table.tableName %></th>
			<% end %>
			
			</tr>
	</thead>
	<tfoot>
		<tr>
			<th>
				<a href='' onclick='subtractRow(); return false;' title='subtract a row'></a>
			</th>
		</tr>
		<tr>
			<th id="indicator_<%= table.id %>" style="display: none;">..saving</th>
			<% if (session[:user_id] == @people.id) %>	
			<th>
				<%= link_to '▼', {:controller => :user_admin, :action => 'add_row', :id => table}, :class => :bold %>
				<%= link_to '▲', {:controller => :user_admin, :action => 'delete_row', :id => table}, :class => :bold %>
			</th>
			
			<th>
				<%= link_to '+', {:controller => :user_admin, :action => 'add_domain', :id => table}, :class => :bold %>
			</th>
			<% end %>
		</tr>
		
					
					
				
	</tfoot>
	<tbody class="line"><%= render(:partial => "domain", :collection => table.domains.sort_by_hit_and_limit(table.row)) %>
	</tbody>
</table>
<script type="text/javascript">


Draggables.addObserver({
    onEnd:function(){
    var delta = $('<%= table_id %>').positionedOffset();
        <%= remote_function :url => {:action => :save_position, :id => table.id},
                            :with => "'deltaX=' + delta[0] + '&deltaY=' + delta[1]",
							:before => "$('indicator_#{table.id}').show( )",
							:complete => "$('indicator_#{table.id}').hide( )"	%>
    }
});


</script>

